$(function(){
	//加载游戏列表
	loadGames();
});

//数据加载
function loadDatas(kindId,serverid){
	
	//游戏id
	var game = $("#game").val();
	if(game == ""){
		game = kindId;
	} else {
		if(game != ""){
			game = game.substring(0, game.indexOf("/"));
		}
	}
	
	//房间id
	var room = $("#room").val();
	if(room == ""){
		room = serverid;
	}
	//页码
	var page = $("#page").val();
	if(page == ""){
		page = 1;
	}
//	alert("room: "+room+"; state: "+state+"; page: "+page);
	//每页显示的条数
	var pageSize = 40;
	
	$.ajax({
		type: "post",
		data: {"game":game, "room":room, "page":page},
		url: "/admin/roomset/historicalThroughput",
		beforeSend: function(){
			$("#load").css("display","block");
		},
		success: function(msg){
			$("#load").css("display","none");
			var datas = msg.records;
			var roomTitle = "";
			//表格数据
			var html = "";
			if(datas.length==0){
				html += "<tr><td colspan='7'>没查询到符合条件的数据~</td></tr>";
			}else{
				for(var i = 0; i<datas.length; i++){
					html += "<tr>";
					html += "<td>"+datas[i].date+"</td>";
					html += "<td>"+datas[i].serverId+"</td>";
					html += "<td>"+datas[i].roomname+"</td>";
					html += "<td>"+datas[i].todayScore+"</td>";
					html += "<td>"+datas[i].outScore+"</td>";
					html += "<td>"+datas[i].eatScore+"</td>";
					html += "<td>"+doubleFormat(datas[i].ttl)+"</td>";
					html += "</tr>";
				}
			}
			$("#databody").html(html);
			
			$("#roomTitle").html(roomTitle);
			
			//分页数据
			var pageInfo = msg.pageInfo;
			//总条数
			var allCount = pageInfo.count;
			$("#count").html(allCount);
			//总页数
			var allPage = Math.ceil(allCount/pageSize);
			if(allPage==0){
				allPage = 1;
			}
			//当前页码
			var now = pageInfo.page;
			
			$("#page").val(now);
			$("#nowPage").html(now);
			$("#allPage").html(allPage);
			$("#pageIpu").val("");
		}
	});
}